/// tree bends in youth
/// 7.11.2023
/// success is doing same thing in every single day!!!
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
using namespace std;
const ll N = 1e5 + 5;
const ll NN = 1e6 + 5;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LG = 18;
int a[N],b[N];
int t[4 * N],p[4 * N];
bool th[4 * N];
void push(int v,int l,int r){
if(p[v] != (-1 * N) && th[v] == 0){
if(l != r){
p[v+v] = p[v];
th[v+v] = 0;
th[v+v+1] = 0;
p[v+v+1] = p[v];
p[v] = (-1 * N);
}
}
}
void upd(int v,int l,int r,int ql,int qr,int dif){
push(v,l,r);
if(ql <= l && r <= qr){
th[v] = 0;
p[v] = dif;
push(v,l,r);
return;
}
if(r <ql || qr < l)return;
int mid = (l + r) / 2;
upd(v+v,l,mid,ql,qr,dif);
upd(v+v+1,mid+1,r,ql,qr,dif);
}
int get(int v,int l,int r,int pos,bool toh){
push(v,l,r);
if(l == r){
if(th[v] == 0)return l + p[v];
else return -1;
}
int mid = (l + r) / 2;
if(pos <= mid)return get(v+v,l,mid,pos,toh);
else get(v+v+1,mid+1,r,pos,toh);
}
void solve(){
int n,m;cin >> n >> m;
for(int i = 1;i <= 4 *n;i++){
th[i] = 1;
if(i > n)continue;
cin >> a[i];
}
for(int i = 1;i <= n;i++)cin >> b[i];
while(m--){
int tp;cin >> tp;
if(tp == 1){
int x,y,k;
cin >> y >>x >> k;
upd(1,1,n,x,(x + k - 1),y - x);
}
else{
int x;cin >> x;
int pos = get(1,1,n,x,1);
if(pos == -1)cout << b[x] << '\n';
else cout << a[pos] << '\n';
}
}
}
main (){
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("rvq.in","r",stdin);
// freopen("rvq.out","w",stdout);
ll abd= 1;
// cin >> abd;
for(ll i = 1;i <= abd;i++){
// cout << "Case " << i << ":\n";
solve();
}
}
478A - Initial Bet | 981A - Antipalindrome |
365A - Good Number | 1204B - Mislove Has Lost an Array |
1409D - Decrease the Sum of Digits | 1476E - Pattern Matching |
1107A - Digits Sequence Dividing | 1348A - Phoenix and Balance |
1343B - Balanced Array | 1186A - Vus the Cossack and a Contest |
1494A - ABC String | 1606A - AB Balance |
1658C - Shinju and the Lost Permutation | 1547C - Pair Programming |
550A - Two Substrings | 797B - Odd sum |
1093A - Dice Rolling | 1360B - Honest Coach |
1399C - Boats Competition | 1609C - Complex Market Analysis |
1657E - Star MST | 1143B - Nirvana |
1285A - Mezo Playing Zoma | 919B - Perfect Number |
894A - QAQ | 1551A - Polycarp and Coins |
313A - Ilya and Bank Account | 1469A - Regular Bracket Sequence |
919C - Seat Arrangements | 1634A - Reverse and Concatenate |